package co.chuangdian.oflauncher.folders.setting;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import cn.onekit.APP;
import cn.onekit.CALLBACK;
import co.chuangdian.oflauncher.R;

public class AddFolder_Step1 extends Fragment {
	public AddFolder_Step1() {

	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		return inflater.inflate(R.layout.foldersetting_add_1, container, false);
	}

	CALLBACK<String> callback;

	public void setData(CALLBACK<String> callback) {
		this.callback = callback;
	}

	EditText nameEditText;

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		nameEditText = (EditText) this.getActivity().findViewById(R.id.nameEditText);
		nameEditText.setOnEditorActionListener(new OnEditorActionListener() {

			@Override
			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
				if (actionId == EditorInfo.IME_ACTION_DONE) {
					name = v.getText().toString();
					APP.hideKeyboard(v);
					callback.run(false, null);
				}
				return false;
			}

		});
	}

	public String name;
}
